package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;

public class MoviesMenu extends Menu {

    MoviesLibrary moviesLib = new MoviesLibrary();
    ArrayList<MenuItem> menuItems =new ArrayList<MenuItem>();

    public MoviesMenu() {
        description = "Movies Menu";
        addItem(new ReturnPreviousMenuItem());
    }

    @Override
    public void addItem(MenuItem menuItem) {
        menuItems.add(menuItem);
    }

    @Override
    public Iterator createIterator() {
        return menuItems.iterator();
    }

    public boolean controller(UserAccount sessionUser) {

        moviesDisplayInterface();

        MenuPrinter menuPrinter = new MenuPrinter(this);
        menuPrinter.printMenu();

        UserChoice userChoice = new UserChoice();
        return menuItems.get( userChoice.getChoice()-1).controller(sessionUser);

    }


    void moviesDisplayInterface() {
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("~~~~~~~~~~ Movies ~~~~~~~~~~~~");
        Vector<String> moviesDetails = moviesLib.getAllItemDetails();
        System.out.println("Title" + "\t" + "Year" + "\t" + "Director" + "\t" + "Rating");
        System.out.println();
        for (String movie : moviesDetails)
            System.out.println(movie);
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    }

}